Technical Q&As


NW 34 - Undefined Routines in Open Transport Libraries (1-June-96)


Q I'm trying to link the Open Transport libraries with the Symantec C++ compiler but it complains that SetSelfAsClient, LoadClass, SetCurrentClient and UnloadClass aren't defined. What's going wrong?


A The routines that are undefined (LoadClass, etc) are part of the ASLM interface. OT uses ASLM as its underlying shared library system, with the ASLM bits wrapped inside standard ".o" (for 68K) and XCOFF/PEF (for PPC) files.

The missing routines are only used by two routines, OTLoadASLMLibrary and OTUnloadASLMLibrary. These routines themselves aren't referenced anywhere, either by the API or by any other OT library.

This works just fine with other environments since they parse libraries from the top down, starting at main and branching outwards to each referenced routine. Because OTLoadASLMLibrary is never referenced, they never detect that LoadClass is undefined.

Symantec C++, however, is more rigorous and notices the missing routines. Symantec's linker has been updated to ignore routines that are undefined and referenced only from routines that are never called. You can enable this update by using the "Smart Check Link" linker option in the latest release of the SC++ environment.

If you don't have this latest update, you can simply 'stub out' these routines in your own source file as shown:

#ifdef __cplusplus
extern "C" {
#endif
	
void SetSelfAsClient(void)
{
		DebugStr("\pSetSelfAsClient -- This is not good.");
}

void LoadClass(void)
{
		DebugStr("\pLoadClass -- This is not good.");
}

void SetCurrentClient(void)
{
		DebugStr("\pSetCurrentClient -- This is not good.");
}

void UnloadClass(void)
{
		DebugStr("\pUnloadClass -- This is not good.");
}

#ifdef __cplusplus
}
#endif
This works because these routines are never actually called by any code. The DebugStrs are there just in case that assertion turns out to be untrue.

Note that the sample uses conditional compilation to ensure that the routines are defined inside an extern "C" { } block, lest the link fail because of the name mangler.



Technical Q&As
Previous Question | Contents | Next Question